package org.dei.perla.utils;

import java.util.ArrayList;

import org.dei.perla.utils.pipe.Pipe;

public class MultiPlexedPipe<E> {
	
	private ArrayList<MultiplexedPipeThread<E>> waiterList;
	private Pipe<E> outputPipe;
	
	public MultiPlexedPipe(String strName){
		waiterList = new ArrayList<MultiplexedPipeThread<E>>();
		outputPipe = new Pipe<E>(strName);
	}
	
	public void addPipe(Pipe<E> aNewPipe){
		MultiplexedPipeThread<E> waiter = new MultiplexedPipeThread<E>(aNewPipe, outputPipe);
		waiterList.add(waiter);
		waiter.start();
		new Thread(waiter).start();
	}
	
	public Pipe<E> getMultiplexedPipe(){
		return outputPipe;
	}
	
}
